package com.ysd.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.ysd.entity.Consume_log;

public interface Consume_logRepository extends JpaRepository<Consume_log, Integer>,JpaSpecificationExecutor<Consume_log>{
	
	List<Consume_log> findByMemberLike(String member);
	
	//离开资源室
	@Transactional 
	@Modifying 
	@Query(value = "update consume_log set out_time=?2 where id=?1", nativeQuery = true)
	public int updateConsume_logById(Integer id,String out_time);	
 
	//通过资源室id和学号同时查询查询
	@Query(value = "select c.* from consume_log c where c.read_room_id=?1 and c.card_no=?2",nativeQuery = true)
	Consume_log findByMemberAndRead_room(String read_room_id,String card_no);
	
}
